Here is the complete scene code for the scene titled “Dark Room.” Following the scene code is a breakdown of the code, with explanations of each section of code.
*************************************************
IF{LOOP#=0}OR{TEXT$=LOOK}THEN
IF{LAMP>PLAYER@}OR{L1#<1}THEN
MOVE{DARK.1}TO{SCENE@}
PRINT{You are in a vary large, dark room. The only thing you can see is a bit of light streaming in from a passageway to the north.}
PRINT{....................................}
PRINT{You are facing NORTH.}
EXIT
MOVE{DARK.1}TO{STORAGE@}
PRINT{You are in a very long, large room. There are passageways to the NORTH and to the SOUTH.}
PRINT{....................................}
PRINT{You are facing NORTH.}
END
IF{TEXT$=SEARCH}THEN
PRINT{..................................}
IF{DARK.1=SCENE@}THEN
PRINT{It's to dark to find anything.}
EXIT
PRINT{There is a pile of trash in the corner.}
EXIT
IF{TEXT$=OPEN}THEN
PRINT{....................................}
IF{TEXT$=SAFE}OR{TEXT$=LOCK}THEN
IF{SAFE.CLOSED=SCENE@}THEN
PRINT{The safe is locked. You must enter the correct combination to open it.}
PRINT{That's not the correct combination to open the safe.}
EXIT
IF{CLICK$=SAFE.CLOSED}OR{CLICK$=CALENDAR.1}THEN
PRINT{....................................}
END
IF{CLICK$=SAFE.OPEN}THEN
SOUND{SQUEEK.1}
MOVE{SAFE.OPEN}TO{STORAGE@}
MOVE{SAFE.CLOSED}TO{SCENE@}
EXIT
IF{TEXT$=GET}OR{TEXT$=TAKE}OR{TEXT$=MOVE}THEN
PRINT{....................................}
IF{TEXT$=CALENDAR}OR{TEXT$=CALENDER}THEN
PRINT{The calendar is glued to the wall. You can't remove it.}
EXIT
END
IF{TEXT$=READ}THEN
IF{TEXT$=CALENDAR}OR{TEXT$=CALENDER}THEN
MOVE{CALENDAR.2}TO{SCENE@}
EXIT
END
IF{CLICK$=CALENDAR.2}THEN
MOVE{CALENDAR.2}TO{STORAGE@}
EXIT
IF{CLICK$=CLIPPING.1}THEN
PRINT{....................................}
MOVE{CLIPPING.1}TO{STORAGE@}
MOVE{CLIPPING}TO{PLAYER@}
PRINT{You found a newspaper clipping on the floor. The clipping is a want ad. To read it, enter "READ CLIPPING."}
EXIT
**************End of code*********************
In this scene, the room is dark unless the player has a lamp, and the lamp is lit. Also, there is a wall safe in the room that requires a combination to open it. On the other wall, there is a calendar the player can read. And there is a newspaper clipping lying on the floor which the player can pick up and read at any time.
The first section of code handles the text description of the scene, and tells the program whether the scene should be dark or lighted:
IF{LOOP#=0}OR{TEXT$=LOOK}THEN
IF{LAMP>PLAYER@}OR{L1#<1}THEN
MOVE{DARK.1}TO{SCENE@}
PRINT{You are in a vary large, dark room. The only thing you can see is a bit of light streaming in from a passageway to the north.}
PRINT{....................................}
PRINT{You are facing NORTH.}
EXIT
MOVE{DARK.1}TO{STORAGE@}
PRINT{You are in a very long, large room. There are passageways to the NORTH and to the SOUTH.}
PRINT{....................................}
PRINT{You are facing NORTH.}
END
>>>In the section above, the first IF/THEN statement determines if the loop # is zero, meaning the player has just come into the scene, or if the player has entered the word “look.” If either of these conditions is true, then the nested statement checks to see if the player does NOT have the lamp, or if the lamp is not lit. The variable L1# is used to tell if the lamp is lit or not. If it is less than 1, then the player has not lit the lamp. If the player does not have the lamp, OR the lamp is not lit, then an object with a darkened drawing of the room is moved to the scene, and a special scene description is printed in the text window, telling the player that the room is dark.
If the player DOES have the lamp, AND the lamp is lit, then the “dark” object is moved to storage (whether or not it is actually in the scene) and the player is given a proper description of the room.<<<
Of course, if the player should try to search while the room is dark, he won’t have much success. So the following code segment checks to see if the “dark” object is in the scene each time the player enters the search command:
IF{TEXT$=SEARCH}THEN
PRINT{..................................}
IF{DARK.1=SCENE@}THEN
PRINT{It's too dark to find anything.}
EXIT
END
>>>If indeed the “dark” object is in the scene, then a brief bit of text tells the player that it is too dark to find anything. This statement closes with EXIT, since we don’t want the program to tell the player anything else. If the dark object is not in the scene, then the nested statement is ignored. There is nothing special we want to tell the player when he or she searches, so the “search” statement closes with END, allowing the program to continue to the Global code, where the default tells the player “You find nothing unusual.”<<<
The next section of code handles the player’s attempt to open the safe. If the safe is closed, the player is told that it is locked and that he must enter a combination to open the safe. If the safe is already open, the the text informs the player of this:
IF{TEXT$=OPEN}THEN
PRINT{....................................}
IF{TEXT$=SAFE}OR{TEXT$=LOCK}THEN
IF{SAFE.CLOSED=SCENE@}THEN
PRINT{The safe is locked. You must enter the correct combination to open it.}
EXIT
PRINT{The safe is already open.}
EXIT
PRINT{What do you want to open?}
EXIT
>>>This requires three nested statements. The first one detects if the player has entered “open.” The second statement determines if the player has also entered the words “safe” or “lock.” The innermost statement checks to see if the safe is actually closed.<<<
The next section of code handles the actual combination:
>>>In the above code, the first statement checks to see if the player has entered the correct combination, in any of four possible variations. If so, then the nested statement detects if the safe is closed. If the combination has been entered, and the safe is closed, then a “twisting” sound is played (to represent the sound of the dial), followed by the sound of the metal hinges as the safe is opened. The SAFE.CLOSED object is moved to storage, and the SAFE.OPEN object is moved to the scene. Then a final statement checks to see if the “key” object is in storage. If it is, then it is moved to the scene, and the player is told that the key was in the safe. If the key is not in storage, then that statement is skipped and the player is told that the safe is empty. This is so that the key won’t keep turning up in the safe over and over if the player closes the safe and reopens it.
Finally, if the safe is already open, then the text is printed that informs the player of this.<<<
The following section handles any incorrect combinations the player may try to enter. If the player enters any number other than the correct combination, it will pass the previous code, and must be wrong. So any number from 0 to 9, regardless of the sequence, will result in the statement below being true, and the player is told that the number is wrong:
PRINT{That's not the correct combination to open the safe.}
EXIT
If the player clicks on the immobile objects in the scene, the following section of code prints a seperator line of periods before the objects’ description is printed:
IF{CLICK$=SAFE.CLOSED}OR{CLICK$=CALENDAR.1}THEN
PRINT{....................................}
END
The code below closes the safe if the player clicks on the SAFE.OPEN object. No text is required for this action. The sound of the hinges is played, the SAFE.OPEN object is returned to storage, and the SAFE.CLOSED object is moved to the scene:
IF{CLICK$=SAFE.OPEN}THEN
SOUND{SQUEEK.1}
MOVE{SAFE.OPEN}TO{STORAGE@}
MOVE{SAFE.CLOSED}TO{SCENE@}
EXIT
The code below handles the player’s attempts to take the calendar on the wall:
IF{TEXT$=GET}OR{TEXT$=TAKE}OR{TEXT$=MOVE}THEN
PRINT{....................................}
IF{TEXT$=CALENDAR}OR{TEXT$=CALENDER}THEN
PRINT{The calendar is glued to the wall. You can't remove it.}
EXIT
END
>>>The first statement above detects if the player has entered the words “get” “take” or “move.” If so then a row of periods is printed, and a nested statement determines if the player has also entered the word “calendar” (or its common misspelling, “calender.” I try to include common misspellings wherever possible to make the game more user-friendly.) If the second statement is true, then the player is told that the calendar is glued to the wall and can’t be moved.<<<
The next section tells the program what to do if the player tries to read the calendar:
IF{TEXT$=READ}THEN
IF{TEXT$=CALENDAR}OR{TEXT$=CALENDER}THEN
MOVE{CALENDAR.2}TO{SCENE@}
EXIT
END
>>>The first statement determines if the word “read” has been entered. If so, then the second statement checks to see if “calendar” has been entered. If that is also true, then the object that is a closeup drawing of the calendar is moved to the scene, so that the player may examine it and see the dates.<<<
Below, if the player clicks on the closeup calendar object (CALENDAR.2) then it is returned to storage:
IF{CLICK$=CALENDAR.2}THEN
MOVE{CALENDAR.2}TO{STORAGE@}
EXIT
Next, if the player clicks on a small drawing of the clipping on the floor (CLIPPING.1) then the actual movable object “clipping” is moved to the player’s possession, and CLIPPING.1 is moved to storage. Text is then printed in the text window telling the player what he has found, and how to read it:
IF{CLICK$=CLIPPING.1}THEN
PRINT{....................................}
MOVE{CLIPPING.1}TO{STORAGE@}
MOVE{CLIPPING}TO{PLAYER@}
PRINT{You found a newspaper clipping on the floor. The clipping is a want ad. To read it, enter "READ CLIPPING."}